<?php 

class Ext_Video_Fetch_Parse_Adapter_Youku extends Ext_Video_Fetch_Parse_Abstract
{
    public function parse()
    {
        $this->_datas['host'] = "youku.com";

        if(preg_match("/\/id_(\w+)\.html/ui", $this->_url, $m) && $m[1]){      
             $this->_datas['viewId'] = $m[1];
             
        }elseif(preg_match("/var videoId2= \'(\w+)\';/ui", $this->_html, $m) && $m[1]){      
             $this->_datas['viewId'] = $m[1];
             
        }

        $this->_datas['url'] = $this->_url;
        if(preg_match("/id=\"download\" _href=\"iku:\/\/\|video\|(http\:\/\/v\.youku\.com\/v_show\/id_[^\|]+?)\|/ui", $this->_html, $m) && $m[1]){      
            $this->_datas['url'] = $m[1];
            
        }elseif(preg_match("/<input type=\"text\" id=\"link1\" value=\"(http\:\/\/v\.youku\.com\/v_show\/id_[^>]+?)\" \/>/ui", $this->_html, $m) && $m[1]){      
            $this->_datas['url'] = $m[1];
            
        }

        if(preg_match("/\<title\>(.+?)\s*[\-\_].*?\<\/title\>/ui", $this->_html, $m) && $m[1]){
            $this->_datas['title'] = $m[1];
            
        }

        if(preg_match("~\_href=\"iku\:\/\/.+?(http\:\/\/[\w\d]+\.ykimg\.com\/[^\|]+?)\|~i", $this->_html, $m) && $m[1]){
            $this->_datas['photo'] = $m[1];
            
        }elseif(preg_match("/pic=(http:\/\/[\w\d]+.ykimg.com\/[^\"]+?)\" target=\"_blank\"><img src=\"http:\/\/static.youku.com\/[^\"]+?\/v\/img\/ico_sina.gif\" \/>[^>]*?<\/a>/usi", $this->_html, $m) && $m[1]){
            $this->_datas['photo'] = $m[1];
            
        }
    }

}
